/**
 *
 */
import Util;
import OpenApi;

import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('nbf', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model AscpPurchasingConsignOrderReceivedFinishedErpSpiRequest {
  extFields?: string(name='extFields', description='附加信息'),
  purchaseOrderNo?: string(name='purchaseOrderNo', description='采购单号'),
  outInboundNo?: string(name='outInboundNo', description='物流单号(LBX)'),
  consignOrderNo?: string(name='consignOrderNo', description='采购批次(发货单号)'),
  tenantId?: string(name='tenantId', description='租户ID'),
  poType?: int32(name='poType', description='单据类型'),
  warehouse?: {
    warehouseName?: string(name='warehouseName', description='仓库名称'),
    warehouseCode?: string(name='warehouseCode', description='仓库编码'),
  }(name='warehouse', description='仓信息'),
  gmtCreate?: string(name='gmtCreate', description='建单时间'),
  items?: [ 
    {
      extFields?: string(name='extFields', description='货品行附加信息'),
      purchaseUnit?: string(name='purchaseUnit', description='采购单位'),
      storageUnit?: string(name='storageUnit', description='库存单位'),
      productId?: long(name='productId', description='货品ID'),
      receivedDefectiveQuantity?: float(name='receivedDefectiveQuantity', description='批次实收残品数量'),
      planQuantity?: float(name='planQuantity', description='批次计划收货数量(发货数量)'),
      orderLineId?: long(name='orderLineId', description='货品行ID'),
      barcode?: string(name='barcode', description='条形码'),
      receivedNormalQuantity?: float(name='receivedNormalQuantity', description='批次实收良品数量'),
      productName?: string(name='productName', description='货品名称'),
    }
  ](name='items', description='货品行列表'),
  gmtReceiveFinish?: string(name='gmtReceiveFinish', description='收货完成时间'),
}

model AscpPurchasingConsignOrderReceivedFinishedErpSpiResponseBody = {
  success?: boolean(name='success', description='是否成功'),
  errorCode?: string(name='errorCode', description='错误编码'),
  errorMsg?: string(name='errorMsg', description='错误信息'),
}

model AscpPurchasingConsignOrderReceivedFinishedErpSpiResponse = {
  headers: map[string]string(name='headers'),
  body: AscpPurchasingConsignOrderReceivedFinishedErpSpiResponseBody(name='body'),
}

async function ascpPurchasingConsignOrderReceivedFinishedErpSpiWithOptions(request: AscpPurchasingConsignOrderReceivedFinishedErpSpiRequest, runtime: Util.RuntimeOptions): AscpPurchasingConsignOrderReceivedFinishedErpSpiResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('AscpPurchasingConsignOrderReceivedFinishedErpSpi', '2021-07-01_20-43-00-935', 'HTTP', 'POST', 'AK', 'json', req, runtime);
}

async function ascpPurchasingConsignOrderReceivedFinishedErpSpi(request: AscpPurchasingConsignOrderReceivedFinishedErpSpiRequest): AscpPurchasingConsignOrderReceivedFinishedErpSpiResponse {
  var runtime = new Util.RuntimeOptions{};
  return ascpPurchasingConsignOrderReceivedFinishedErpSpiWithOptions(request, runtime);
}

model AscpPurchasingPurchaseOrderCancelledErpSpiRequest {
  purchaseOrderNo?: string(name='purchaseOrderNo', description='采购单号'),
  supplierId?: long(name='supplierId', description='供应商ID'),
  tenantId?: string(name='tenantId', description='租户ID'),
  remark?: string(name='remark', description='备注，取消原因'),
}

model AscpPurchasingPurchaseOrderCancelledErpSpiResponseBody = {
  success?: boolean(name='success', description='是否成功'),
  errorCode?: string(name='errorCode', description='错误编码'),
  errorMsg?: string(name='errorMsg', description='错误信息'),
}

model AscpPurchasingPurchaseOrderCancelledErpSpiResponse = {
  headers: map[string]string(name='headers'),
  body: AscpPurchasingPurchaseOrderCancelledErpSpiResponseBody(name='body'),
}

async function ascpPurchasingPurchaseOrderCancelledErpSpiWithOptions(request: AscpPurchasingPurchaseOrderCancelledErpSpiRequest, runtime: Util.RuntimeOptions): AscpPurchasingPurchaseOrderCancelledErpSpiResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('AscpPurchasingPurchaseOrderCancelledErpSpi', '2021-07-01_20-43-00-935', 'HTTP', 'POST', 'AK', 'json', req, runtime);
}

async function ascpPurchasingPurchaseOrderCancelledErpSpi(request: AscpPurchasingPurchaseOrderCancelledErpSpiRequest): AscpPurchasingPurchaseOrderCancelledErpSpiResponse {
  var runtime = new Util.RuntimeOptions{};
  return ascpPurchasingPurchaseOrderCancelledErpSpiWithOptions(request, runtime);
}

model AscpPurchasingPurchaseOrderCreatedErpSpiRequest {
  supplierName?: string(name='supplierName', description='供应商名称'),
  supplierId?: long(name='supplierId', description='供应商ID'),
  contractType?: int32(name='contractType', description='经营模式'),
  expectArriveTime?: string(name='expectArriveTime', description='期望到仓时间'),
  remark?: string(name='remark', description='备注'),
  supplierCode?: long(name='supplierCode', description='供应商编码'),
  warehouse?: {
    warehouseName?: string(name='warehouseName', description='仓库名称'),
    warehouseCode?: string(name='warehouseCode', description='仓库编码'),
  }(name='warehouse'),
  gmtCreate?: string(name='gmtCreate', description='建单时间'),
  contractVersion?: string(name='contractVersion', description='合同版本'),
  extFields?: string(name='extFields', description='附加信息'),
  purchaseOrderNo?: string(name='purchaseOrderNo', description='采购单号'),
  fullBulkFlag?: int32(name='fullBulkFlag', description='存储类型'),
  tenantId?: string(name='tenantId', description='租户ID'),
  poType?: int32(name='poType', description='单据类型'),
  items?: [ 
    {
      extFields?: string(name='extFields', description='货品行附加信息'),
      industryName?: string(name='industryName', description='一级行业名称'),
      itemId?: long(name='itemId', description='商品ID'),
      purchaseUnit?: string(name='purchaseUnit', description='采购单位'),
      brandName?: string(name='brandName', description='品牌名称'),
      storageUnit?: string(name='storageUnit', description='库存单位'),
      productId?: long(name='productId', description='货品ID'),
      planQuantity?: float(name='planQuantity', description='采购数量'),
      orderLineId?: long(name='orderLineId', description='货品行ID'),
      barcode?: string(name='barcode', description='条形码'),
      categoryName?: string(name='categoryName', description='叶子类目名称'),
      skuId?: long(name='skuId', description='SKU ID'),
      productName?: string(name='productName', description='货品名称'),
    }
  ](name='items', description='采购货品行列表'),
  contractCode?: string(name='contractCode', description='合同编号'),
  internationTradeClause?: string(name='internationTradeClause', description='贸易条款'),
}

model AscpPurchasingPurchaseOrderCreatedErpSpiResponseBody = {
  success?: boolean(name='success', description='是否成功'),
  errorCode?: string(name='errorCode', description='错误编码'),
  errorMsg?: string(name='errorMsg', description='错误信息'),
}

model AscpPurchasingPurchaseOrderCreatedErpSpiResponse = {
  headers: map[string]string(name='headers'),
  body: AscpPurchasingPurchaseOrderCreatedErpSpiResponseBody(name='body'),
}

async function ascpPurchasingPurchaseOrderCreatedErpSpiWithOptions(request: AscpPurchasingPurchaseOrderCreatedErpSpiRequest, runtime: Util.RuntimeOptions): AscpPurchasingPurchaseOrderCreatedErpSpiResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('AscpPurchasingPurchaseOrderCreatedErpSpi', '2021-07-01_20-43-00-935', 'HTTP', 'POST', 'AK', 'json', req, runtime);
}

async function ascpPurchasingPurchaseOrderCreatedErpSpi(request: AscpPurchasingPurchaseOrderCreatedErpSpiRequest): AscpPurchasingPurchaseOrderCreatedErpSpiResponse {
  var runtime = new Util.RuntimeOptions{};
  return ascpPurchasingPurchaseOrderCreatedErpSpiWithOptions(request, runtime);
}

model AscpPurchasingPurchaseOrderReceivedFinishedErpSpiRequest {
  extFields?: string(name='extFields', description='附加信息'),
  purchaseOrderNo?: string(name='purchaseOrderNo', description='采购单号'),
  tenantId?: string(name='tenantId', description='租户ID'),
  poType?: int32(name='poType', description='单据类型'),
  warehouse?: {
    warehouseName?: string(name='warehouseName', description='仓库名称'),
    warehouseCode?: string(name='warehouseCode', description='仓库编码'),
  }(name='warehouse', description='仓信息'),
  gmtCreate?: string(name='gmtCreate', description='建单时间'),
  items?: [ 
    {
      extFields?: string(name='extFields', description='货品行附加信息'),
      purchaseUnit?: string(name='purchaseUnit', description='采购单位'),
      storageUnit?: string(name='storageUnit', description='库存单位'),
      productId?: long(name='productId', description='货品ID'),
      receivedDefectiveQuantity?: float(name='receivedDefectiveQuantity', description='实收残品数量'),
      planQuantity?: float(name='planQuantity', description='采购数量'),
      orderLineId?: long(name='orderLineId', description='货品行ID'),
      barcode?: string(name='barcode', description='条形码'),
      receivedNormalQuantity?: float(name='receivedNormalQuantity', description='实收良品数量'),
      productName?: string(name='productName', description='货品名称'),
    }
  ](name='items', description='货品行列表'),
  gmtReceiveFinish?: string(name='gmtReceiveFinish', description='收货完成时间'),
}

model AscpPurchasingPurchaseOrderReceivedFinishedErpSpiResponseBody = {
  success?: boolean(name='success', description='是否成功'),
  errorCode?: string(name='errorCode', description='错误编码'),
  errorMsg?: string(name='errorMsg', description='错误信息'),
}

model AscpPurchasingPurchaseOrderReceivedFinishedErpSpiResponse = {
  headers: map[string]string(name='headers'),
  body: AscpPurchasingPurchaseOrderReceivedFinishedErpSpiResponseBody(name='body'),
}

async function ascpPurchasingPurchaseOrderReceivedFinishedErpSpiWithOptions(request: AscpPurchasingPurchaseOrderReceivedFinishedErpSpiRequest, runtime: Util.RuntimeOptions): AscpPurchasingPurchaseOrderReceivedFinishedErpSpiResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('AscpPurchasingPurchaseOrderReceivedFinishedErpSpi', '2021-07-01_20-43-00-935', 'HTTP', 'POST', 'AK', 'json', req, runtime);
}

async function ascpPurchasingPurchaseOrderReceivedFinishedErpSpi(request: AscpPurchasingPurchaseOrderReceivedFinishedErpSpiRequest): AscpPurchasingPurchaseOrderReceivedFinishedErpSpiResponse {
  var runtime = new Util.RuntimeOptions{};
  return ascpPurchasingPurchaseOrderReceivedFinishedErpSpiWithOptions(request, runtime);
}

